package org.jackysoft.controller;

import java.util.Collection;

import javax.annotation.Resource;

import org.jackysoft.annotations.Logger;
import org.jackysoft.controller.base.AbstractController;
import org.jackysoft.entity.SecurityRole;
import org.jackysoft.service.SecurityRoleService;
import org.jackysoft.util.OperationType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;



@Logger(label = "授权", logType = OperationType.System)
@Controller
@RequestMapping("/securole")
public class SecuRoleController extends AbstractController<SecurityRole> {

	
	@Resource
	private SecurityRoleService service;

	
	@RequestMapping("/byuser/{username}")
	public void byuser(@PathVariable String username,@ModelAttribute  Collection<SecurityRole> beans) throws Exception {
		beans = service.findByUser(username);		
	}
	
	
	@RequestMapping("/priority")
	public void priority(@ModelAttribute  Collection<SecurityRole> beans) throws Exception {
		beans = service.findAll();
		
	}

	@RequestMapping("/apply/{username}")
	public void apply(@PathVariable String username) throws Exception {
		service.enabled(username);
		
	}


	@RequestMapping("/appenduser")
	public void appenduser(String name,Collection<String> users) throws Exception {
		service.appendUsers(name, users);
	}
}
